package redora.client.validation;

import com.google.gwt.libideas.validation.client.ErrorHandler;
import com.google.gwt.libideas.validation.client.Subject;
import com.google.gwt.libideas.validation.client.validator.RegExValidator;

public class NumCheckValidator extends RegExValidator {

	final static String numCheck = "^\\d*$";

	public NumCheckValidator() {
		super(numCheck);
	}

	public NumCheckValidator(String regEx) {
		super(regEx);
	}

	@Override
	public String createErrorMessage(String subjectLabel, String answer) {
		return subjectLabel + " must be a number !";
	}

	public void checkValid(Subject element, ErrorHandler handler) {
		if (element.getValue() != null
				&& element.getValue().toString().length() > 0)
			super.checkValid(element, handler);
	}

}
